﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EZCRS.HCMS.Data;
using EZCRS.HCMS.Entity;
using System.Data;
using System.Data.SqlClient;

namespace EZCRS.HCMS.SqlClient
{
    public class sql_AdmScoreSetUp
    {
        private string SqlStr = "";
        #region 酒店或集团积分设置信息列表
        /// <summary>
        /// 酒店或集团积分设置列表
        /// </summary>
        /// <param name="OrgId">组织编号</param>
        /// <param name="OrgType">组织类型 2=集团  1=酒店 3=hubs1</param>
        /// <returns></returns>
        public DataTable ScoreSetUp_List(string OrgId, string OrgType)
        {
            if (OrgType == "3")
                SqlStr = "select * from hfg_scoresetup where orgtype=3";
            else if (OrgType == "0")
                SqlStr = "select * from hfg_scoresetup where orgid=" + OrgId + " and orgtype=0 ";
            else
                SqlStr = "select * from hfg_scoresetup where orgid=" + OrgId + " and orgtype=1 ";
            DataTable dt = ExecSql.GetDataSet(SqlStr).Tables[0];
            if (dt != null)
                return dt;
            else
                return null;
        }
        #endregion

        #region 酒店或集团积分设置信息添加、修改
        /// <summary>
        /// 修改或添加酒店或集团积分设置信息
        /// </summary>
        /// <returns></returns>
        public bool ScoreSetUp_Add(string Orgid, string Orgtype, string Stpname, string Startdate, string Enddate, string Lvlid, string Hotelstar, string Roomtype, string Unitscore, string Stpcomment, string Indate, string Inuser, string Stpid)
        {
            SqlParameter[] pam = new SqlParameter[12];
            pam[0] = new SqlParameter("@orgid", Orgid);
            pam[1] = new SqlParameter("@orgtype", Orgtype);
            pam[2] = new SqlParameter("@stpname", Stpname);
            pam[3] = new SqlParameter("@startdate", Startdate);
            pam[4] = new SqlParameter("@enddate", Enddate);
            pam[5] = new SqlParameter("@lvlid", Lvlid);
            pam[6] = new SqlParameter("@hotelstar", Hotelstar);
            pam[7] = new SqlParameter("@roomtype", Roomtype);
            pam[8] = new SqlParameter("@unitscore", Unitscore);
            pam[9] = new SqlParameter("@stpcomment", Stpcomment);
            pam[10] = new SqlParameter("@indate", Indate);
            pam[11] = new SqlParameter("@inuser", Inuser);


            if (Stpid != "")
                SqlStr = "update hfg_scoresetup set orgid=@orgid,orgtype=@orgtype,stpname=@stpname,startdate=@startdate,enddate=@enddate,lvlid=@lvlid,hotelstar=@hotelstar,roomtype=@roomtype,unitscore=@unitscore,stpcomment=@stpcomment,indate=@indate,inuser=@inuser where stpid=" + Stpid + "";
            else
                SqlStr = "insert into hfg_scoresetup(orgid,orgtype,stpname,startdate,enddate,lvlid,hotelstar,roomtype,unitscore,stpcomment,indate,inuser) values(@orgid,@orgtype,@stpname,@startdate,@enddate,@lvlid,@hotelstar,@roomtype,@unitscore,@stpcomment,@indate,@inuser)";
            if (ExecSql.SqlExecNoquery(SqlStr, pam) > 0)
                return true;
            else
                return false;
        }
        #endregion
        #region 酒店或集团积分设置Info数据的显示,显示一条数据
        public DataRow ScoreSetUp_Item(string Stpid)
        {
            try
            {
                return ExecSql.GetDataSet("select * from hfg_scoresetup where stpid=" + Stpid).Tables[0].Rows[0];
            }
            catch
            {
                return null;
            }
        }
        #endregion
        #region 酒店或集团积分设置的删除
        public bool ScoreSetUp_Del(string Stpid)
        {
            string sql = "", msg = "";
            sql = "delete from hfg_scoresetup where stpid=" + Stpid + "";
            if (ExecSql.SqlExecNoquery(sql) > 0)
                return true;
            else
                return false;
        }
        #endregion
    }
}
